﻿@inherits LayoutComponentBase
@inject I18n I18n

<MApp>
    <CascadingValue Value="I18n">
        <MAppBar Elevation=0 App MaxHeight=60
            Class="@($"{(_pageTab == PageModes.PageTab ?"mx-6":"mx-6 rounded-b-4")}")">
            <Favorite />
            <MSpacer />
            <Search />
            <MIcon Size=20 Class="ml-5" Color="neutral-lighten-3">mdi-message-processing-outline</MIcon>
            <MIcon Size=20 Class="ml-5" Color="neutral-lighten-3" OnClick="()=> _showSetting = true">mdi-cog-outline
            </MIcon>
            <Language OnLanguageChanged="OnLanguageChanged" />
            <Login />
        </MAppBar>

        <Navigation />

        <MMain Class="fill-lighten-1" Style="padding-top:60px">
            @if (_pageTab == PageModes.PageTab)
            {
                <PageTabs>
                    @Body
                </PageTabs>
            }
            else
            {
                <div class="pa-6 max-width">
                    <Breadcrumb></Breadcrumb>
                    @Body
                </div>
            }
        </MMain>
        <Settings @bind-PageModel="_pageTab" @bind-Show=_showSetting />
    </CascadingValue>
</MApp>

@code {
    private bool _showSetting;
    private string? _pageTab;

    void OnLanguageChanged(CultureInfo culture)
    {
        I18n.SetCulture(culture);
    }
}